package com.foreknow.service.impl;


import com.foreknow.dao.impl.GuestbookDaoImpl;
import com.foreknow.db.DBManager;
import com.foreknow.service.GuestbookService;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

public class GuestbookServiceImpl implements GuestbookService {


    @Override
    public List<Object> queryInfo() {
        //连接数据库
        DBManager dbManager = DBManager.getInstance();
        //调用连接数据库的方法
        Connection conn = dbManager.getConnection();
        //创建dao层的对象
        GuestbookDaoImpl guestbookDao = new GuestbookDaoImpl();
        //调用AdminDaoImpl对象中的 public void setConnection(Connection connection)方法连接数据库
        guestbookDao.setConnection(conn);
        List<Object> list = null;
        try {
            list = guestbookDao.getQueryAll();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return list;

    }
}
